function [matOut,cellOut]=structMult2mat(strucPivot,varargin) 
% =====================================================================
%
% function [matOut,cellOut]=structMult2mat(strucPivot,varargin) 
%
% Given the structure strucPivot, use its fieldnames as a pivot 
% create a matrix that extracts the same fields for all other structures 
% and reports them in a matrix, as well as a cell 
% 
% This function calls struct2matMatch.m for each pair.
%
% Alejandro Justiniano Feb 2013 
% =====================================================================
fields=fieldnames(strucPivot); 
Nfields=length(fields); 
matOut =zeros(Nfields,nargin); 
matOut(:,1)=cell2mat(struct2cell(strucPivot)); 
for ii=1:nargin-1 
    currStruct=varargin{ii}; 
    [~,rightTemp]=struct2matMatch(strucPivot,currStruct); 
    matOut(:,ii+1)=rightTemp;
end 
cellOut=[fields(:) num2cprec(matOut,5)]; 

end 